from django.db import models

# Create your models here.


class Area(models.Model):
    '''
    省,市联动
    '''
    name = models.CharField(max_length=20, verbose_name="名称")
    # 外键                   自关联
    parent = models.ForeignKey('self', on_delete=models.SET_NULL, related_name='subs', null=True, blank=True, verbose_name='上级⾏政区划')


    class Meta:
        # 表名
        db_table = "tb_areas"
        #　在管理的时候使用
        verbose_name = "⾏政区划"
        verbose_name_plural = "政区划"

    def __str__(self):
        return self.name